<template>
  <div class="content">
    <div class="toolbox-title">
      <div style="font-family: '微软雅黑'; font-size: 18px; font-weight: bold"
        >不良率分析
      </div>
    </div>

    <div id="main" :style="{ width: '100%', height: '300px' }"> </div>
  </div>
</template>

<script lang="ts" setup>
  import { reactive, onMounted } from 'vue';
  import * as echarts from 'echarts';

  // type EChartsOption = echarts.EChartsOption;
  // let chartDom: any = document.getElementById('main');
  // let myChart = echarts.init(chartDom);
  // let option: EChartsOption;
  let echart = echarts;
  const option = () => {
    let chart = echart.init(document.getElementById('main') as any, 'dark');
    chart.setOption({
      backgroundColor: '',
      tooltip: {
        trigger: 'item'
      },
      legend: {
        top: '5%',
        left: 'center'
      },
      series: [
        {
          name: 'Access From',
          type: 'pie',
          radius: ['40%', '70%'],
          avoidLabelOverlap: false,
          itemStyle: {
            borderRadius: 10,
            borderColor: '#fff',
            borderWidth: 2
          },
          label: {
            show: false,
            position: 'center'
          },
          emphasis: {
            label: {
              show: true,
              fontSize: 40,
              fontWeight: 'bold'
            }
          },
          labelLine: {
            show: false
          },
          data: [
            { value: 1048, name: 'Search Engine' },
            { value: 735, name: 'Direct' },
            { value: 580, name: 'Email' },
            { value: 484, name: 'Union Ads' },
            { value: 300, name: 'Video Ads' }
          ]
        }
      ]
    });
  };

  onMounted(() => {
    option();
  });
  // option && myChart.setOption(option);

  const menu = [];
</script>

<style scoped lang="less">
  .content {
    width: 100%;
    height: 405px;
    background-color: #fff;
    border-radius: 10px;
    position: relative;
    .toolbox {
      &-title {
        width: 100%;
        height: 20%;
        padding: 15px;
      }
    }
  }

  #main {
  }
</style>
